Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't focus input until screen transition has ended #3719

Merged
merged 3 commits into from
Jun 22, 2021

Conversation

roryabraham
Copy link
Contributor

@roryabraham roryabraham commented Jun 22, 2021

Details

Don't focus the input until the screen transition animation has completed.

Fixed Issues

Fixes #3604

Tests / QA Steps

  1. Go to staging.expensify.cash and login
  2. Tap avatar
  3. Tap profile
  4. Tap add phone number
  5. Verify that the screen transitions normally. The phone number input should focus, but on iOS Safari the keyboard input may not open. Apple purposely prevents this for non-user-triggered events. I could not find a workaround, but we shouldn't block here.

Tested on

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

image

Mobile Web

image

Desktop

iOS

Android

@roryabraham roryabraham self-assigned this Jun 22, 2021
@roryabraham roryabraham marked this pull request as ready for review June 22, 2021 17:36
@roryabraham roryabraham requested a review from a team as a code owner June 22, 2021 17:36
@MelvinBot MelvinBot requested review from ctkochan22 and removed request for a team June 22, 2021 17:36
@OSBotify
Copy link
Contributor

⚠️ ⚠️ Heads up! This pull request has the CP Staging label. ⚠️ ⚠️
Merging it will cause it to be immediately deployed to staging, even if the open StagingDeployCash deploy checklist is locked.

src/pages/settings/AddSecondaryLoginPage.js Outdated Show resolved Hide resolved
@@ -72,6 +72,8 @@ class AddSecondaryLoginPage extends Component {
this.formType = props.route.params.type;
this.submitForm = this.submitForm.bind(this);
this.validateForm = this.validateForm.bind(this);

this.phoneNumberInputRef = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to add this here and it's fine that it stays undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marc and I added a rule to the style guide about this a few months ago: https://github.com/Expensify/Expensify.cash/blob/main/STYLE.md#use-refs-appropriately:

all refs should be declared in the constructor, rather than inline. This makes it easier to quickly see what refs are declared in the component

Is this something you disagree with?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I do disagree with that.

Defining them in the constructor doesn't do anything (computationally). I think we should avoid code that doesn't do anything, just to make something easier to find. If I follow the current style guide suggestion and apply it to other situations, that would lead us to a place where all variables and class properties are defined in the constructor. I just think it makes it messy and bloats the code without any real purpose.

all refs should be declared in the constructor, rather than inline

I also think that this isn't really correct. It's not being "declared" inline, it's just being assigned a value inline, which doesn't change even if the variable is initialized in the constructor.

This makes it easier to quickly see what refs are declared in the component

This implies that the problem being solved was "refs are hard to find and locate", which I think is a problem that I don't agree with. Maybe there is a good example of where refs are hard to find and we can narrow down why they are hard to find?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defining them in the constructor doesn't do anything (computationally). I think we should avoid code that doesn't do anything, just to make something easier to find.

It's true this doesn't change anything and declaring refs in the constructor isn't necessary – the sole purpose is to improve readability.

This implies that the problem being solved was "refs are hard to find and locate", which I think is a problem that I don't agree with.

Yeah, that was the implied problem, but I do think it's pretty subjective. Since it's not unanimous that this rule improves the readability of components that use refs, I think it makes sense to err on the side of not adding lines of code that don't do anything.

This style rule was introduced in this PR, so I'm going to migrate this discussion over there. If others agree with your reasoning here, then we should be able to just revert that PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for moving that convo over to that PR and for listening!

src/pages/settings/AddSecondaryLoginPage.js Outdated Show resolved Hide resolved
@roryabraham
Copy link
Contributor Author

@parasharrajat and I found a workaround for the keyboard not opening on focus in iOS Safari, but it comes with a consequence where the weird half-transition bug displays for a moment before the keyboard will open. We think it's better not to implement that workaround, because it negatively affects all platforms in order to provide a workaround for Safari. This PR in its current state works on all platforms but requires one extra click on iOS safari, which is not a big deal

@roryabraham
Copy link
Contributor Author

Updated

@OSBotify
Copy link
Contributor

🚀 Cherry-picked to staging in version: 1.0.73-1🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production in version: 1.0.73-3🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to staging in version: 1.0.73-4🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production in version: 1.0.74-0🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mWeb - Safari- Page gets distorted tapping add phone number in profile
4 participants